<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.10/vue.js"></script>
</head>
<body>
<div id="app">
    <!--
        .prevent修饰符:
        阻止当前事件的默认行为
        .once修饰符:
        当前事件只能触发一次
    -->
    <button @contextmenu.prevent.once="contextMenu">
        右键我,看我有没有菜单了
    </button>

    <!--
        .capture修饰符:
            控制当前事件在捕获阶段触发(如果不写,默认都是在冒泡阶段触发)
        .stop修饰符:
            阻止当前事件的传播
            如果要阻止捕获,在最外层元素上书写
            如果要阻止冒泡,在最内层元素上书写
      -->
    <div @click.capture.stop="outerClick">
        outer
        <div @click="innerClick">
            inner
            <div @click.stop="contentClick">
                content
            </div>
        </div>
    </div>

    <hr/>
    <!--
        .self修饰符:
        控制只有在当前绑定事件的元素上
      -->
    <div @click.self="outerClick">
        outer
        <div @click.self="innerClick">
            inner
            <div @click.self="contentClick">
                content
            </div>
        </div>
    </div>

    <!--
        按键别名修饰符
        .enter(配合键盘事件使用):当输入回车的时候执行回调函数
      -->
    <input type="text" @keyup.enter="publish"/>
</div>
<script>
    const vm = new Vue({
        el:"#app",
        data(){
            return{

            }
        },
        methods:{
            contextMenu(){
                console.log("右键触发");
            },
            outerClick(){
                console.log("outerClick")
            },
            innerClick(){
                console.log("innerClick")
            },
            contentClick(){
                console.log("contentClick")
            },
            publish(){
                console.log("publish")
            }
        }
    })
</script>
</body>
</html>